#pragma once

#include <QtNodes/NodeDelegateModel>

#include <QtCore/QJsonObject>
#include <QtCore/QObject>
#include <QtWidgets/QLabel>

#include <iostream>
#include <vector>

#include "globaldata.h"

class DecimalData;

using QtNodes::NodeData;
using QtNodes::NodeDataType;
using QtNodes::NodeDelegateModel;
using QtNodes::PortIndex;
using QtNodes::PortType;

/// The model dictates the number of inputs and outputs for the Node.
/// In this example it has no logic.

class MyNodeData : public NodeData
{
public:
    NodeDataType type() const override { return NodeDataType{ "MyNodeData", "My Node Data" }; }
};

class SimpleNodeData : public NodeData
{
public:
    NodeDataType type() const override { return NodeDataType{ "SimpleData", "Simple Data" }; }
};

class UserOperationDataModel : public NodeDelegateModel
{
    Q_OBJECT

public:
    UserOperationDataModel();
    ~UserOperationDataModel() = default;

public:
    unsigned int nPorts(PortType portType) const override;

    NodeDataType dataType(PortType portType, PortIndex portIndex) const override;

    std::shared_ptr<NodeData> outData(PortIndex port) override;

    void setInData(std::shared_ptr<NodeData> data, PortIndex portIndex) override;

    QWidget *embeddedWidget() override { return nullptr; }

    bool portCaptionVisible(PortType portType, PortIndex portIndex) const override;

    QString caption() const override;

    QString portCaption(PortType portType, PortIndex portIndex) const override;

    QString name() const override;

protected:
    bool eventFilter(QObject* object, QEvent* event) override;

    virtual void compute();

private:
    Unit m_unit;
};
